From: Andrew Cooper Date: Fri, 22 Jan 2016 15:18:02 +0000 (+0100) Subject: x86/domctl: break out logic to update domain state from cpuid information X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1870 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=277df04ba9635d698c9189dbf893e12b0cb73cf2;p=xen.git x86/domctl: break out logic to update domain state from cpuid information Later changes will add to this logic. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 95b074710d..1d71216195 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -47,6 +47,40 @@ static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop) return iop->remain ? -EFAULT : 0; } +static void update_domain_cpuid_info(struct domain *d, + const xen_domctl_cpuid_t *ctl) +{ + switch ( ctl->input[0] ) + { + case 0: { + union { + typeof(boot_cpu_data.x86_vendor_id) str; + struct { + uint32_t ebx, edx, ecx; + } reg; + } vendor_id = { + .reg = { + .ebx = ctl->ebx, + .edx = ctl->edx, + .ecx = ctl->ecx + } + }; + + d->arch.x86_vendor = get_cpu_vendor(vendor_id.str, gcv_guest); + break; + } + + case 1: + d->arch.x86 = (ctl->eax >> 8) & 0xf; + if ( d->arch.x86 == 0xf ) + d->arch.x86 += (ctl->eax >> 20) & 0xff; + d->arch.x86_model = (ctl->eax >> 4) & 0xf; + if ( d->arch.x86 >= 0x6 ) + d->arch.x86_model |= (ctl->eax >> 12) & 0xf0; + break; + } +} + #define MAX_IOPORTS 0x10000 long arch_do_domctl( @@ -698,36 +732,8 @@ long arch_do_domctl( ret = -ENOENT; if ( !ret ) - { - switch ( ctl->input[0] ) - { - case 0: { - union { - typeof(boot_cpu_data.x86_vendor_id) str; - struct { - uint32_t ebx, edx, ecx; - } reg; - } vendor_id = { - .reg = { - .ebx = ctl->ebx, - .edx = ctl->edx, - .ecx = ctl->ecx - } - }; + update_domain_cpuid_info(d, ctl); - d->arch.x86_vendor = get_cpu_vendor(vendor_id.str, gcv_guest); - break; - } - case 1: - d->arch.x86 = (ctl->eax >> 8) & 0xf; - if ( d->arch.x86 == 0xf ) - d->arch.x86 += (ctl->eax >> 20) & 0xff; - d->arch.x86_model = (ctl->eax >> 4) & 0xf; - if ( d->arch.x86 >= 0x6 ) - d->arch.x86_model |= (ctl->eax >> 12) & 0xf0; - break; - } - } break; }